<?php

class IndexController extends Controller
{
	private $_model;
	
	public $layout='column2';
		
	/**
	 * @过滤器
	 */
	public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
		);
	}
	
	/*
	 * 一些特殊的规则
	 */
	public function accessRules()
	{
		return array(
			array('allow', // 允许验证用户访问所有动作
				'users'=>array('@'),
			),
			array('deny',  // 禁止用户访问所有动作
				'users'=>array('*'),
			),
		);
	}
	
	/**
	 *	默认执行动作
	 */
	public function actionIndex()
	{
		//实例化条件 
		$criteria=new CDbCriteria(
			array(
				'condition'=>'user_id='.Yii::app()->user->getId().' and type != "comment"',
				//'condition'=>'user_id='.Yii::app()->user->getId().'',
				'order'=>'create_time DESC'
			)
		);

		//数据仓库
		$dataProvider=new CActiveDataProvider('UserFeedIndex', array(
		    'criteria'=>$criteria
		));

		//渲染到index.html
		$_refresh = Yii::app()->request->getParam('act');
		if($_refresh == 'refresh')
		{
			$this->renderPartial('index',array(
				'dataProvider'=>$dataProvider,
			));
		}
		else
		{
			$this->render('index',array(
				'dataProvider'=>$dataProvider,
			));
		}
	}
}